#include <glm\glm.hpp>

//#include <gl/glew.h>
#include <gl/glfw.h>

void DrawCircle2D(float x, float y, float r, bool filled)
{
        if( filled )
                glBegin(GL_POLYGON);
        else
                glBegin(GL_LINE_STRIP);
        for (int i = 0; i < 18; i++)
        {
                float ang = i * 6.28381f / 17.0f;
                float xp = r * cosf(ang);
                float zp = r * sinf(ang);
                glVertex2f(x + xp, y + zp);
        }
        glEnd();
}



class Bullet
{
public:
	Bullet()
	{
		timeToLive = -1; // Bullets are initially dead
	}

	~Bullet()
	{
		printf("bullet dtor should not happen\n");
	}

	void draw()
	{
		DrawCircle2D( pos[0], pos[1], 4, true );
	}

	void update( double dt )
	{
		timeToLive -= dt;
		pos += 100.0f * dir * (float) dt;
	}

	void setFinished()
	{
		timeToLive = -1.0;
	}

	static bool canRemove(const Bullet *bulletPtr)
	{
		return bulletPtr->timeToLive <= 0.0;
	}

	void shoot( glm::vec2 &pos, glm::vec2 &dir, double ttl ) 
	{
		timeToLive = ttl;
		this->pos = pos;
		this->dir = dir;
	}


	public:
	glm::vec2 pos;
private:
	glm::vec2 dir;
	double timeToLive;
};